<template>
<div class="vue-office-pdf-box">
  <vue-office-docx v-if="previewUrl.indexOf('pdf') === -1 && previewUrl.indexOf('PDF') === -1" :src="previewUrl" @rendered="rendered"/>
  <vue-office-pdf v-else :src="previewUrl" @rendered="rendered" :options="{ lazy: false }" @error="errorHandler" />
  <!-- :staticFileUrl="'http://10.10.1.17:3000/assets'" -->
</div>
</template>
<script>
//引入VueOfficeDocx组件
import VueOfficeDocx from '@vue-office/docx'
import VueOfficePdf from '@vue-office/pdf'
// import '@vue-office/docx/lib/index.css'
export default {
  components:{
    VueOfficeDocx,
    VueOfficePdf
  },
  data(){
    return {
      previewUrl: ''
    }
  },
  created() {
    this.previewUrl = this.$route.query.url || 'https://zsjl.oss-cn-beijing.aliyuncs.com/WorksAgreement/2023-12-15/5f7d074d-605f-4222-9142-3140de198b2f.pdf'
  },
  computed: {
  },
  methods:{
    rendered(){
      console.log("渲染完成")
    },
    errorHandler(err) {
      console.log(err)
    }
  }
}
</script>
<style lang="scss">
.vue-office-pdf-box{
  height: calc(100vh -  env(safe-area-inset-bottom) - 83px);
  overflow-y: scroll;
  .vue-office-pdf {
    height: 200% !important;
  }
}
</style>
